package com.api.department.gettags;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.zyncro.api.IDepartmentApiService;
import com.zyncro.api.exceptions.ZyncroApiException;
import com.zyncro.api.model.CollectionResultApi;
import com.zyncro.api.model.TagApi;

@ContextConfiguration(locations = "classpath:/department/department-members.xml")
public class GetTags extends AbstractApiTest {

	@Value("#{user_contact.appId}")
	private String userUrn;

	@Value("#{user_contact.password}")
	private String userPassword;

	@Value("#{department_toGetTags.urn}")
	private String iddepartment;

	@Value("#{department_toGetTags.totalTags}")
	private int totalTags;

	@BeforeClass
	protected void loginUser() throws Exception {

		getApi().login(userUrn, userPassword);
	}

	@Test
	public void testTags() throws ZyncroApiException {

		CollectionResultApi<TagApi> result = getApi().getService(IDepartmentApiService.class).getTags(iddepartment);

		Assert.assertTrue(result.getElements().size() >= 0 && result.getElements().size() <= 2, "Department tags between 0 and 2");
		Assert.assertEquals(result.getElements().size(), totalTags, "Total tags");
	}
}
